<!DOCTYPE html>
<html lang="en">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>个人中心-充值</title>
	<link href="#" rel="shortcut icon">
	<script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
	<script src="js/md5.js"></script>
	<script src="js/layer.js"></script>
	<script type="text/javascript" src="js/public.js"></script>
	<link type="text/css" rel="stylesheet" href="css/layout.css">
	<link rel="stylesheet" type="text/css" href="css/bifa.css">

</head>

<body>
	<iframe src="./header.html" id="header" width="100%" height="160" frameborder="0" scrolling="no" ></iframe>		
	<div class="standing">
		<div class="stand-w w clearfix">
			<div class="stand-left">
				<div class="user-person">
					<div class="user-mess">
						<div class="mess-pic"><img /></div>
						<div class="mess-name">
							<p>账户名：<span id="user-name"></span></p>
							<p>余额：<span id="user-total"></span></p>
						</div>
					</div>
					<div class="tw-btn">
						<span class="recharge-btn hover">充值</span>
						<span class="withdraw-btn ">提现</span>
					</div>
				</div>
				<ul class="stand-ul">
					<li>
						<a href="lottery.html">
							<div class="stand-list">
								<img src="images/lottery.png" >
								<span>中奖历史</span>
							</div>
						</a>
					</li>
					<li >
						<a href="standings.html">
							<div class="stand-list">
								<img src="images/standings.png" >
								<span>战绩</span>
							</div>
						</a>
					</li>
					<li >
						<a href="detail.html">
							<div class="stand-list">
								<img src="images/detail.png" >
								<span>账户明细</span>
							</div>
						</a>
					</li>
					<li>
						<a href="transaction.html">
							<div class="stand-list">
								<img src="images/transaction.png" >
								<span>交易记录</span>
							</div>
						</a>
					</li>
					<li >
						<a href="personal.html">
							<div class="stand-list">
								<img src="images/personal.png" >
								<span>个人资料</span>
							</div>
						</a>
					</li>
					<li>
						<a id="server">
							<div class="stand-list">
								<img src="images/server.png" >
								<span>客服</span>
							</div>
						</a>
					</li>
					<li>
						<a href="information.html">
							<div class="stand-list">
								<img src="images/information.png" >
								<span>消息中心</span>
							</div>
						</a>
					</li>
				</ul>
			</div>
			<div class="stand-right">
				<div class="person-top">
					<h3>充值</h3>
				</div>
				<div class="reg-money">
					<span>充值金额</span>
					<input type="text" placeholder="输入金额" id="depositMoney">
					<span>元</span>
				</div>
				<div class="reg-selecmoney">
					<span>100元</span>
					<span>200元</span>
					<span>300元</span>
					<span>500元</span>
				</div>
				<div class="reg-sendtype">线上充值：</div>
				<div class="reg-type" id="xs">

				</div>
				<div class="reg-sendtype">线下充值：</div>
				<div class="reg-type" id="xx">
					
				</div>
				<div class="reg-comit">
					<button id="reg-once">立即充值</button>
				</div>
			</div>
		</div>
	</div>

	<iframe src="./footer.html" width="100%" height="105" frameborder="0" scrolling="no" ></iframe>	

	<script>
		// 个人资料
		$(function(){

			var uid = getCookie('uid');
			var userObj = jsonObj;//个人信息
			userObj.uid = uid;
			var index = 1,type="",id = '12';
			//用户信息
			$ajax(
				url+'member_info',
				'post',
				userObj,
				function(data){
					
					if(data.data.avatar){
						$('.mess-pic img,.li-pic img').attr('src',data.data.avatar);//用户头像

					}else{
						$('.mess-pic img,.li-pic img').attr('src','images/user-pic.png');
					}

					$('#user-name').text(data.data.username);//会员名
					$('#user-total').text(data.data.balance);//余额
					$('.person-top').data('bankName',data.data.bankName);
					$('.person-top').data('bankAcco',data.data.bankCard)

					$('#server').click(function(){
						openQQ(data.data.serviceQQ)
					})

					deposit(data) //提现

				},
				function(data){
					layer.msg(data.msg)
				}
			)
			
			// 获取充值列表
			$ajax(
				url+'pay_type_list',
				'post',
				userObj,
				function(data){
					
					var xs = data.data.xs;
					var xx = data.data.xx;
					// console.log(data);
					var res1 = '';
					for(var i = 0,iL=xs.length;i<iL;i++){
						res1+='<input type="radio" name="sex" data-index="1" data-id="'+xs[i].id+'" />'+
								'<img src="'+xs[i].logurl+'" alt="'+xs[i].title+'">'+
								'<span>'+xs[i].title+'</span>';
						
					}
					var res2 = '';
					for(var i = 0,iL=xx.length;i<iL;i++){
						res2+='<input type="radio" name="sex" data-type="'+xx[i].sktype+'" data-index="3" data-id="'+xx[i].id+'" />'+
								'<img src="'+xx[i].logurl+'" alt="'+xx[i].title+'">'+
								'<span>'+xx[i].title+'</span>';
					}
					
					$('#xs').html(res1)
					$('#xx').html(res2)
					$('#xs input').eq(0).attr('checked','checked')
					// 选择充值方式
					$('.reg-type input').click(function(){
						id = $(this).data('id');
						type = $(this).data('type');
						index = $(this).data('index');
						
					})
				},
				function(data){
					layer.msg(data.msg)
				}
			)
			// 选择充值金额
			$('.reg-selecmoney span').click(function(){
				$(this).addClass('hover').siblings().removeClass('hover');
				$('#depositMoney').val(parseInt($(this).text()));
				userObj.depositMoney = $('#depositMoney').val();
				
			})

			// 立即充值
			
			$('#reg-once').click(function(){
				userObj.depositMoney = $('#depositMoney').val();
				userObj.type = index;
				userObj.id = parseInt(id);
				if(index == 1){
					if($('#depositMoney').val() == ''){
						layer.msg('请填写充值金额');
						
					}else{
						$ajax(
							url+'sendPay_new',
							'post',
							userObj,
							function(data){
								
								window.open('./pay.html?type='+index +'&id='+id+'&money='+$('#depositMoney').val());
							},
							function(data){
								
								layer.msg(data.msg)
							}
						)
					}
						
					}else if(index == 3){ //跳转线下充值
						
						if(type == 'yhk'){
							userObj.type = type;
							
							layer.open({
								type: 1,
								title: false,
								closeBtn: 0, //不显示关闭按钮
								anim: 2,
								area: ['380px', '400px'],
								shadeClose: true, //开启遮罩关闭
								content: $('#yhk'),
								end:function(){
									layer.closeAll();
									window.location.reload()
								}
							});
							$ajax(
								url+'offline_payment',
								'post',
								userObj,
								function(data){
									
									$('.yhk-crad').text(data.data[0].acc);
									$('.lay-yhk').data('id',data.data[0].id);
									$('.yhk-type').text(data.data[0].title);
									$('.yhk-name').text(data.data[0].name);
									$('.yhk-adress').text(data.data[0].fhname);
								},
								function(data){

									layer.msg(data.msg)
								}

							)
							$('.yhk-comit').click(function(){

								userObj.type = index;
								userObj.depositMoney = $('.yhk-realmoney').val()
								userObj.depositors = $('.yhk-realname').val();
								userObj.id = parseInt($('.lay-yhk').data('id'));
								userObj.bank = $('.person-top').data('bankName');
								userObj.bankAcco = $('.person-top').data('bankAcco');
								
								$ajax(
									url+'sendPay_new',
									'post',
									userObj,
									function(data){
										
										layer.msg(data.msg,{time:1000},function(){
											layer.closeAll();
										});
									},
									function(data){
										layer.msg(data.msg)
									}
								)
							})

						}else if(type == 'zfb' || type == 'wx'){
							
							userObj.type = type;
							layer.open({
								type: 1,
								title: false,
								closeBtn: 0, //不显示关闭按钮
								anim: 2,
								area: ['380px', '420px'],
								shadeClose: true, //开启遮罩关闭
								content: $('#wx'),
								end:function(){
									layer.closeAll();
									window.location.reload()
								}
							});
							$ajax(
								url+'offline_payment',
								'post',
								userObj,
								function(data){
									
									$('.wx-account').text(data.data[0].acc);
									$('.lay-yhk').data('id',data.data[0].id);
									$('.wx-pic').attr('src',data.data[0].pic);
								},
								function(data){
									layer.msg(data.msg)
								}

							)
							$('.yhk-comit').click(function(){
								
								userObj.type = index;
								userObj.depositMoney = $('.reg-Money').val()
								userObj.depositors = $('.reg-name').val();
								userObj.id = parseInt($('.lay-yhk').data('id'));
								userObj.bankAcco = $('.reg-count').val();
								
								$ajax(
									url+'sendPay_new',
									'post',
									userObj,
									function(data){
										
										layer.msg(data.msg,{time:1000},function(){
											layer.closeAll();
										});
									},
									function(data){
										layer.msg(data.msg)
									}
								)
							})
						}
						
						$('.yhk-reset').click(function(){
							layer.closeAll();
						})
						
					}else{
						layer.msg('请选择充值类型')
					}
						
			})

		})
	</script>
</body>
<div class="lay-yhk" id="yhk" style="display:none">
	<div class="yhk-mess" style="margin-bottom:20px;">
		<div class="yhk-debit">
			<span>充值银行：</span>
			<span class="yhk-type yhk-span"></span>
		</div>
		<div class="yhk-debit">
			<span>收款姓名：</span>
			<span class="yhk-name yhk-span"></span>
		</div>
		<div class="yhk-debit">
			<span>收款账号：</span>
			<span class="yhk-crad yhk-span"></span>
		</div>
		<div class="yhk-debit">
			<span>开户网点：</span>
			<span class="yhk-adress yhk-span"></span>
		</div>
	</div>
	<div class="yhk-hr"></div>
	<div class="yhk-cun" style="margin-top:10px;">
		<div class="yhk-inp">
			<span>充值金额：</span>
			<input type="text" placeholder="请输入存款金额"  class="yhk-realmoney"/>
		</div>
		<div class="yhk-inp">
			<span>存款姓名：</span>
			<input type="text" placeholder="请输入存款人姓名" class="yhk-realname"/>
		</div>
	</div>
	<div class="yhk-tips">
		<p>贴心提醒：充值完成后，请等待3-5分钟重新刷新页面，财务收到款项后会立即为您上分。</p>
	</div>
	<div class="yhk-but" style="margin-top:20px;">
		<button class="yhk-comit">提交</button>
		<button class="yhk-reset">取消</button>
	</div>
</div>
<!-- 微信支付宝 -->
<div class="lay-yhk" id="wx" style="display:none">
	<div class="yhk-mess">
		<p class="wx-title"><span>收款人账号：</span> <span class="wx-account"></span></p>
		<img  alt="" class="wx-pic">
	</div>
	<div class="yhk-cun">
		<div class="yhk-inp">
			<span>充值金额</span>
			<input type="text" placeholder="请输入存款金额" class="reg-Money"/>
		</div>
		<div class="yhk-inp">
			<span>存入账号</span>
			<input type="text" placeholder="请输入存款账号" class="reg-count"/>
		</div>
		<div class="yhk-inp">
			<span>存款人姓名</span>
			<input type="text" placeholder="请输入存款人姓名" class="reg-name"/>
		</div>
	</div>
	<div class="yhk-tips">
		<p>贴心提醒：充值完成后，请等待3-5分钟重新刷新页面，财务收到款项后会立即为您上分。</p>
	</div>
	<div class="yhk-but">
		<button class="yhk-comit">提交</button>
		<button class="yhk-reset">取消</button>
	</div>
</div>
</html>